package com.gukun.springboot.tdengine.pojo;

import io.swagger.v3.oas.annotations.media.Schema;

import java.io.Serial;
import java.io.Serializable;

/**
 * className: DbConfig
 * desc:
 * user: gukun
 * date: 2024/9/8 14:31
 */
public class DBConfig implements Serializable {

    public static final String JDBC_URL = "jdbc:TAOS-WS://%s:%s?user=%s&password=%s";
    @Serial
    private static final long serialVersionUID = 1L;
    @Schema(description = "数据库地址", example = "127.0.0.1")
    private String host;
    @Schema(description = "数据库端口", example = "6041")
    private int port;
    @Schema(description = "数据库用户名", example = "root")
    private String username;
    @Schema(description = "数据库密码", example = "taosdata")
    private String password;
    @Schema(description = "数据库名称", example = "")
    private String dbName;

    public DBConfig(String host, int port, String username, String password) {
        this.host = host;
        this.port = port;
        this.username = username;
        this.password = password;
    }

    public DBConfig(){

    }

    // Getters

    public String getHost() {
        return host;
    }

    public int getPort() {
        return port;
    }

    public String getUsername() {
        return username;
    }

    public String getPassword() {
        return password;
    }

    // Setters
    public void setHost(String host) {
        this.host = host;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    //getters and setters
    public String getDbName() {
        return dbName;
    }

    public void setDbName(String dbName) {
        this.dbName = dbName;
    }

    public String getJdbcUrl() {
        return String.format(JDBC_URL, host, port, username, password);
    }


}
